<%--
 *  File:    VisitProcessProdEdit.jsp
 *  @Author: Tao Wei
 *  Date:    2013-2-6

 *  Copyright (C) 2000 - 2013 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>
<%@ page import="com.oval.util.OvalLabel"%>
<%@ page import="com.oval.util.OvalCustomMessage"%>
<%@ page import="com.oval.util.OvalCustomColumn"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>
<%
	  //init param
  String privilegeCode = "H0252";
  String strTableName = "v_visitprocessprodgroup";
  String strModuleName = "CRM";
  	String contextPath = request.getContextPath();
%>

<%@ include file="/inc/Security.inc"%>
<%@ include file="/inc/PageDefault.inc"%>
<%@include file="/inc/Print.inc"%>
<%@ include file="/inc/FrmDefault.inc"%>

<iframe name="reloadHandler" style="display:none" ></iframe>
<html>
<head>
<title>VisitProcessProdEdit</title>
<PageFlow:CheckPageFlow pageName="p_visitprocessprodgroupedit" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<script language="JavaScript" src="../js/ScriptLib.js"></script>
<script language="JavaScript" src="../js/keyFunction.js"></script>
<script language="JavaScript" src="../js/Calendar.js"></script>
<script language="JavaScript" src="../js/SummaryDivision.js"></script>
<%@ include file="/inc/SummaryDivision.inc"%>
<%
  HashMap userinfo = new HashMap();
  userinfo = (HashMap)session.getAttribute("userinfo");
  Integer orgid=new Integer(-1);
  String neworgid = null;
  if(userinfo.get("orgid")!=null)
  orgid = (Integer)userinfo.get("orgid");
  neworgid = orgid.toString();
    String paraIsDefault = "";
  	String strIsDefault = null;
	if("Y".equals(((String)pageContext.getAttribute("isdefault")))) {
		strIsDefault = "&isdefault=Y";
		paraIsDefault = "Y";
	}else if ("N".equals(((String)pageContext.getAttribute("isdefault")))) {
		strIsDefault = "&isdefault=N";
		paraIsDefault = "N";
	}
		String isNew = "";
		  if("Y".equals((String)pageContext.getAttribute("isNew"))) {
				isNew = "Y";
			}else if ("N".equals((String)pageContext.getAttribute("isNew"))) {
				isNew = "N";
			}
          Vector totalsummary = (Vector) pageContext.getAttribute("visitprocessprodinfo");
          if (totalsummary == null)
              totalsummary = new Vector();
	%>
<script>
function page_summary(actionvalue,orderbyname){
	  var editform = summaryPrepare(actionsummaryform,actionvalue,orderbyname);
	  editform.action = "VisitProcessProdGroupEdit.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>";
	  editform.target = "_self";
	  isRunning = true;
	  editform.submit();
}

var popwindow;
function page_selectProd(){
   
	var url = "<%=contextPath%>/masterdata/upm/ProductbrandPopWindow.jsp?visitprocessid="+document.actionsummaryform.visitprocessid.value+"&zyldatacategory=23"+"&<%= OvalTools.randomURL()%>";
	var windowAttribute = "height=250, width=400,top=100,left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
  	if(popwindow!=null) popwindow.close();
  	popwindow = window.open(url,null,windowAttribute);
}

function set_orgNameByPopWindow(id,code,name){
	var frm = document.actionsummaryform;
	frm.prodgroupids.value = id;
	frm.productgroupcode.value = code;
	frm.productgroupname.value = name;
}

function page_add(){
	var frm = document.actionsummaryform;
	if(isEmpty(frm.prodgroupids.value)) {
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Product",false)) %>");
		return;
	}
	frm.actionname.value = "add";
	frm.target = "_self";
	isRunning = true;
	frm.submit();
}

function page_delete(){
	if(nullChecked(document.actionsummaryform.deleteids,"<%=JspHelper.filterNull(totalsummary.size())%>"))
	  {
	    alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD") %>");
	    return;
	  }
	if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE")%>") ) 
	    return;
	    var frm = document.actionsummaryform;
	    frm.actionname.value = "delete";
		frm.target = "_self";
		isRunning = true;
		frm.submit();
}

function page_back()
{  
  parent.location.href = "VisitProcessSummary.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%><%=JspHelper.filterNull( strIsDefault)%>";
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="actionsummaryform" method="post" action="<%=contextPath %>/Dispatcher" target="_parent">
<input type="hidden" name="pagename" value="p_visitprocessprodgroupedit">
<input type="hidden" name="actionname">   
<input type="hidden" name="isdefault" value="<%= paraIsDefault %>">
<input type="hidden" name="isNew" value="<%= isNew %>">
<custom:hidden property="visitprocessid" />
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td>
				<table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">
					<tr>
						<td colspan="3" class="td_right">
							<a onclick='page_add()'><custom:button type="2"	label="L_Add" imgsrc="add_btn.gif" border="0" style="width:60" /></a>
							<a onclick="page_delete()"><custom:button type="2" label="L_Delete" imgsrc="delete_btn.gif" border="0" style="width:60" /></a>
						</td>
					</tr>
					<tr class="deepblue-left">
						<td width="5%" class="title_center">&nbsp;</td>
						<td width="20%" class="title_center"><a href="javascript:page_summary('orderby','productgroupcode')"><%= label.getLabelName("L_ProdGroupCode") %></a></td>
						<td width="75%" class="title_center"><a href="javascript:page_summary('orderby','productgroupname')"><%= label.getLabelName("L_ProductGroupName") %></a></td>
					</tr>
					<%
						int i=0; 
						Integer idx = new Integer(-1);
                        boolean bHasChecked = false;
                        String strClassType = "";
               %>
					<logic:iterate id="onerow" collection="<%=totalsummary%>" indexId="orderid">
              
            <%
					HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
					if(i%2 == 1){
						strClassType = "td-listrom";
					}else{
						strClassType = "";
					}
					i++;
					idx = new Integer(i-1);
			%>
					<tr class="<%=JspHelper.filterNull( strClassType )%>">
						<td class="td_center">
							<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull(tempMap.get("visitprocessprodgroupid") )%>" class="checkbox">
						</td>
						<td nowrap>&nbsp;<custom:write name="onerow" property="productgroupcode" nbsp="true" /></td>
						<td>&nbsp;<custom:write name="onerow" property="productgroupname" nbsp="true" /></td>
					</tr>
					</logic:iterate>
					<tr>
						<td>&nbsp;</td>
						<td>&nbsp;<custom:text name="newhash" property="productgroupcode" size="20" readonly="true" />
							<a onclick="page_selectProd();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a>
							<custom:hidden  property="prodgroupids" />
						</td>
						<td>&nbsp;<custom:text name="newhash" property="productgroupname" size="100" readonly="true" /></td>
					</tr>
					<%@ include file="/inc/SummaryAction.inc"%>
				</table>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td class="summary_top"></td>
					</tr>
					<tr>
						<td class="td_center">
							<a onclick="page_back();"><custom:button type="1" label="L_Back" imgsrc="new.gif" border="0" style="width:60" /></a>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>
</body>
</html>


